﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PostBasedPaginationTests.aspx.cs" Inherits="OpenWaves.Web.Tests.PostBasedPaginationTests" MasterPageFile="TestCase.master" %>

<asp:Content runat="server" ID="Head" ContentPlaceHolderID="head">
    <style type="text/css">
        .PageButton
        {
            border: solid black;
            padding: 5px;
            margin: 5px;
            min-width: 20px;
            text-align: center;
        }
    </style>    
</asp:Content>

<asp:Content runat="server" ID="TestCase" ContentPlaceHolderID="TestCasePlaceHolder">
    <ow:OptionalContentPlaceholder runat="server" ID="paginationPlaceHolder" DataItem="<%#this.Numbers.CurrentPage%>">
        <div>
            Showing items: <%#this.Numbers.CurrentPage.FirstItemNumber%>  - <%#this.Numbers.CurrentPage.LastItemNumber%>
        </div>

        <div>
            <ul>
                <asp:Repeater runat="server" DataSource="<%#this.Numbers.CurrentPage.Items%>">
                    <ItemTemplate>
                        <li><%#Container.DataItem%></li>
                    </ItemTemplate>
                </asp:Repeater>
            </ul>
        </div>
        <ow:Pager runat="server" OnPageCommand="OnPageCommand">
            <Template>
                <ow:PageButton runat="server" Page="<%#this.Numbers.CurrentPage.IsFirst ? null : this.Numbers.FirstPage%>" Text="First" />

                <ow:PageButton runat="server" Page="<%#this.Numbers.PreviousPage%>" Text="Previous" />

                <asp:PlaceHolder runat="server" Visible="<%#this.Numbers.VisiblePages.First().IsFirst == false%>">
                    <span>...</span>
                </asp:PlaceHolder>

                <ow:PageRepeater runat="server" DataSource="<%#this.Numbers.VisiblePages%>">
                    <ItemTemplate>
                        <ow:PageButton runat="server" Page="<%#Container.Item%>" />
                    </ItemTemplate>
                </ow:PageRepeater>

                <asp:PlaceHolder runat="server" Visible="<%#this.Numbers.VisiblePages.Last().IsLast == false%>">
                    <span>...</span>
                </asp:PlaceHolder>

                <ow:PageButton runat="server" Page="<%#this.Numbers.NextPage%>" Text="Next" />

                <ow:PageButton runat="server" Page="<%#this.Numbers.CurrentPage.IsLast ? null : this.Numbers.LastPage%>" Text="Last" />
            </Template>

            <PageButtonTemplate>
                <asp:LinkButton runat="server" 
                                CssClass="PageButton" 
                                CommandName="ChangePage" CommandArgument="<%#Container.Page.Index%>" 
                                ToolTip='<%#Container.Page.FirstItemNumber + " - " + Container.Page.LastItemNumber%>'>
                    <%#Container.Text ?? Container.Page.Number.ToString()%>
                </asp:LinkButton>
            </PageButtonTemplate>

            <UnavailablePageButtonTemplate>
                <span class="PageButton Disabled">
                    <%#Container.Text%>
                </span>
            </UnavailablePageButtonTemplate>

            <SelectedPageButtonTemplate>
                <span class="PageButton Current">
                    <%#Container.Page.Number%>
                </span>
            </SelectedPageButtonTemplate>
        </ow:Pager>        
    </ow:OptionalContentPlaceholder>
</asp:Content>